package com.lap.framework.generator.domain.template.strategy;

import com.lap.framework.generator.application.assembler.Transformer;
import com.lap.framework.generator.domain.FileModel;
import com.lap.framework.generator.domain.TemplateModel;
import com.lap.framework.generator.domain.template.CodeContext;
import com.lap.framework.generator.domain.template.CodeTemplate;
import com.lap.framework.generator.domain.template.TemplateGenerator;
import com.lap.framework.generator.domain.valueobject.CodeType;
import java.util.List;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class Domain implements CodeTemplate<FileModel> {

  @Override
  public CodeType getType() {
    return CodeType.DOMAIN_MODEL;
  }

  @Override
  public List<FileModel> generate(CodeContext context) {
    TemplateModel model = Transformer.transform(context.tableMeta(), context.envConfig());
    String[] domainPackName = {model.getBasePackage(), "domain", model.getModule()};
    String[] domainFileName = {model.getClassName()};
    return List.of(
        TemplateGenerator.generateFile(
            model, domainPackName, domainFileName, "java", "domain/Entity.java.ftl"));
  }
}
